from mosquitto import *

def on_connect(mosq, obj, rc):
    print("Connected to MQTT broker: rc="+str(rc))

def on_message(mosq, obj, msg):
    print("Got msg:", msg.payload.decode("utf-8"))

def on_subscribe(mosq, obj, mid, granted_qos):
    print("Subscribed: "+str(mid)+" "+str(granted_qos))

mqttc = Mosquitto()
mqttc.on_connect = on_connect
mqttc.on_subscribe = on_subscribe
mqttc.on_message = on_message
mqttc.connect("test.mosquitto.org")
#mqttc.connect("fe80::a00:27ff:fe31:bdc7%eth0")
mqttc.loop_start()

mqttc.subscribe("cjtest/#")
print("I am waiting here...")

while (True):
	pass
